package com.cgbg.config;


import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class FanoutRabbitConfig {

    /**
     * 声明队列
     *
     * @return
     */
    @Bean
    public Queue fanoutQueueA() {
        return new Queue("fanout.queue.A");
    }

    @Bean
    public Queue fanoutQueueB() {
        return new Queue("fanout.queue.B");
    }

    @Bean
    public Queue fanoutQueueC() {
        return new Queue("fanout.queue.C");
    }

    /**
     * 声明交换机
     *
     * @return
     */
    @Bean
    public FanoutExchange fanoutExchange() {
        return new FanoutExchange("fanoutExchange");
    }

    /**
     * 绑定队列和交换机
     *
     * @return
     */
    @Bean
    public Binding bindingExchangeA() {
        return BindingBuilder.bind(fanoutQueueA()).to(fanoutExchange());
    }

    @Bean
    public Binding bindingExchangeB() {
        return BindingBuilder.bind(fanoutQueueB()).to(fanoutExchange());
    }

    @Bean
    public Binding bindingExchangeC() {
        return BindingBuilder.bind(fanoutQueueC()).to(fanoutExchange());
    }


}
